//分类相关操作
import request,{Method} from '@/libs/api.js'

//获取分类选择组件的数据结果
export function getCateTreeComponent(){
  return request({
      url : `/product/category/getCateTreeComponent`,
      method: Method.GET,
  })
}

// 查出所有的分类以及子分类，以树形结构组装起来返回给前端
export function listWithTree(){
    return request({
        url : `/product/category/getCateTree`,
        method: Method.GET,
    })
}

export function addCate (params) {
    return request({
      url: '/product/category/addCate',
      method: Method.POST,
      data: params
    });
}

// 修改分类信息
export function editCate (params) {
    return request({
      url: '/product/category/editCate',
      method: Method.PUT,
      data: params
    });
}

// 禁用分类
export function disableCate (cateId) {
  return request({
    url: `/product/category/disableCate/${cateId}`,
    method: Method.PUT,
  });
}

// 禁用分类
export function enableCate (cateId) {
  return request({
    url: `/product/category/enableCate/${cateId}`,
    method: Method.PUT,
  });
}

// 获取一级分类
export function getIndexCateLevel1(){
  return request({
      url : `/product/category/getIndexCateLevel1`,
      method: Method.GET,
  })
}

// 根据id获取下一级子分类
export function getCateTreeById(cateId){
  return request({
      url : `/product/category/getCateTreeById/${cateId}`,
      method: Method.GET,
  })
}

//根据cateId获取它的父分类将其组合起来
export function getCateParentAndMerge(cateId){
  return request({
      url : `/product/category/getCateParentAndMerge/${cateId}`,
      method: Method.GET,
  })
}

// 增加品牌和分类的关联
export function addCateBrandRelation (params) {
  return request({
    url: '/product/categorybrandrelation/addCateBrandRelation',
    method: Method.POST,
    data: params
  });
}

//获取适配前端的Cascader组件的分类树
export function getCateByCascader(){
  return request({
      url : `/product/category/getCateByCascader`,
      method: Method.GET,
  })
}